<template>
  <div>
    <div>嘿嘿</div>
  <div>哈哈</div>
    <div>你是猪</div>
    <!-- <van-nav-bar
      title="用户登录"
      left-text="返回"
      left-arrow
      @click-left="onClickLeft"
    />-->
    <MyNavcomponent title="商城登录" />
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="用户名"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="密码"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px;">
        <van-button round block type="info" @click="onSubmit">登录</van-button>
      </div>
    </van-form>

    <div class="checkBox">
        <van-checkbox v-model="rememberMe" shape="square" @chang='test'>记住密码</van-checkbox>
       <router-link tag="p" to="/registry">没有账号去注册</router-link>

    </div>

  </div>
</template>
<script>
import MyNavcomponent from "../components/personal/MyNavcomponent";
import { getLogin } from "../api/shop-api/shop-api";
export default {
  data() {
    return {
      username: "",
      password: "",
      rememberMe: true,
      // test:''
    };
  },
  created(){
    // console.log(this.rememberMe)
  },
  methods: {
    onSubmit(values) {
      values.preventDefault();
      let formData = new FormData();
      formData.append("username", this.username);
      formData.append("password", this.password);
      formData.append("rememberMe", this.rememberMe);
      getLogin(formData)
        .then(res => {
          console.log(res);
          // this.$store.commit('changeIsLogin',{islogin=true})
          // sessionStorage.setItem("loginInfo", JSON.stringify(res.data));
          this.$router.push("/personal"); // 登陆成功后默认跳转的路由
        })
        .catch();
    },
    test(){
console.log(rememberMe)
  },
  },

  components: {
    MyNavcomponent
  }
};
</script>
<style scoped>
/* .van-checkbox {
  margin-left: 15px;
} */
.checkBox {
  padding-left: 15px;
}
</style>
